// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3)
// Source File Name:   Tyg_txQuery1.java


//Changing this program to allow update

package MaintMenu.VenPricingUpdMasterFiles;

import javax.swing.*;
import java.sql.*;

public class test2
{

    public test2()
    {
        String a= null;
        String b= null;
        String c= null;
        String d= null;

        try
        {
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            String dataSourceName = "dbLI";
            String dbURL = (new StringBuilder()).append("jdbc:odbc:").append(dataSourceName).toString();
            Connection conLI = DriverManager.getConnection(dbURL, "", "");

            Statement stli1 = conLI.createStatement();

            String dataSourceName6 = "dbBL";
            String dbURL6 = (new StringBuilder()).append("jdbc:odbc:").append(dataSourceName6).toString();
            Connection conBK = DriverManager.getConnection(dbURL6, "", "");
            Statement st6 = conBK.createStatement();
            Statement stbk1 = conBK.createStatement();
            Statement stbk2 = conBK.createStatement();

            long containerKey = 0L;


            String duedate = null;
            String duedate1 = null;
            long invid = 0L;
            String part_no = null;
            double quantity = 0.0D;
            double unitprice = 0.0D;
            String description = null;
            String description1 = null;

            //String[] invFields = {"CategoryID", "[Part#]", "Description", "UnitType", "Unit", "UnitCost", "SellingPrice", "InStock","Onorder","OnHold","OnRMA", "ParValue", "Location", "Serialized", "[Vendor#]", "Discontinued", "Weight","Taxable", "Vendor1ID", "Vendor2ID", "Vendor3ID", "LPP", "LPF", "LDP", "LQP", "[UPC#]", "RevenueGLID", "InventoryGLID", "CurrentCost", "WarehouseID", "[Product#]", "Internet", "InternetPrice", "COGID", "AddInFulfillmentAllowed", "Make", "Mdl", "ModelType", "BeginYr", "EndYr", "Prefix", "NAGSCode", "DNKCode", "CIF", "RetailPrice", "SellingPrice2", "[Memo]", "WestWP", "FOB_T, ECP", "PPGPrice", "SLPrice", "MPrice", "ShapeID", "Country", "[BIN#]","PARTSLINK", "PRPKey", "PPGLoc", "InStock1", "POSITION", "NEW_DES","CAPA"};


            //                st1.execute("INSERT INTO tblInventory ( CategoryID, [Part#], Description, UnitType, Unit, UnitCost, SellingPrice, InStock, ParValue, Location, Serialized, [Vendor#], Discontinued, Weight, Taxable, Vendor1ID, Vendor2ID, Vendor3ID, LPP, LPF, LDP, LQP, [UPC#], RevenueGLID, InventoryGLID, CurrentCost, WarehouseID, [Product#], Internet, InternetPrice, COGID, AddInFulfillmentAllowed, Make, Mdl, ModelType, BeginYr, EndYr, Prefix, NAGSCode, DNKCode, CIF, RetailPrice, SellingPrice2, [Memo], WestWP, FOB_T, ECP, PPGPrice, SLPrice, MPrice, ShapeID, Country, [BIN#],PARTSLINK, PRPKey, PPGLoc, InStock1, POSITION, NEW_DES ) SELECT b.CategoryID, b.[Part#], b.Description, b.UnitType, b.Unit, b.UnitCost, b.SellingPrice, b.InStock, b.ParValue, b.Location, b.Serialized, b.[Vendor#], b.Discontinued, b.Weight, b.Taxable, b.Vendor1ID, b.Vendor2ID, b.Vendor3ID, b.LPP, b.LPF, b.LDP, b.LQP, b.[UPC#], b.RevenueGLID, b.InventoryGLID, b.CurrentCost, 2, b.[Product#], b.Internet, b.InternetPrice, b.COGID, b.AddInFulfillmentAllowed, b.Make, b.Mdl, b.ModelType, b.BeginYr, b.EndYr, b.Prefix, b.NAGSCode, b.DNKCode, b.CIF, b.RetailPrice, b.SellingPrice2, b.Memo, b.WestWP, b.[FOB_T], b.ECP, b.PPGPrice, b.SLPrice, b.MPrice, b.ShapeID, b.Country, b.[BIN#], b.PARTSLINK, b.PRPKey, b.PPGLoc, b.InStock1, B.POSITION, B.NEW_DES FROM [D:\\DAILYBACKUP1\\LIH\\TEST].tblInventory AS b LEFT JOIN tblinventory AS c ON b.[part#]=c.[part#] WHERE isnull(c.[part#]);");
            try
            {
//                        st6.execute("delete * from tblbc_work;");
//                        st6.execute("delete * from tblbc_temp;");
//                        //create an entry in tblcontainerheader in Brooklyn
//                        st6.execute("insert into tblcontainerheader(containerkey,container,arrival) values (" + containerKey + ", '" + container + "',#" + duedate1 + "#);");
                //get purchaseorderdetail by poid(i.e. MR130503BKgn) from Hicksville Data
//                stli1.execute("select [part#] as part_no, duedate, invid, quantity, unitprice, description from tblpurchaseorderdetail where poid = " + poid + ";");

                //Include all field in Hicksville except INVID (first colume
//                stli1.execute("SELECT CategoryID, [Part#], Description, UnitType, Unit, UnitCost, SellingPrice, InStock,Onorder,OnHold,OnRMA, ParValue, Location, Serialized, [Vendor#], Discontinued, " +
//                        " Weight, Taxable, Vendor1ID, Vendor2ID, Vendor3ID, LPP, LPF, LDP, LQP, [UPC#], RevenueGLID, InventoryGLID, CurrentCost, WarehouseID, [Product#], Internet, InternetPrice, COGID," +
//                        " AddInFulfillmentAllowed, Make, Mdl, ModelType, BeginYr, EndYr, Prefix, NAGSCode, DNKCode, CIF, RetailPrice, SellingPrice2, [Memo], WestWP, FOB_T, ECP, PPGPrice, SLPrice, MPrice, " +
//                        " ShapeID, Country, [BIN#],PARTSLINK, PRPKey, PPGLoc, InStock1, POSITION, NEW_DES,CAPA " +
//                        " From tblinventory;");
                String[] invFields = {"Make","Mdl","ModelType"};
                String query ="Select [Part#],Make,Mdl,ModelType from tblinventory;";
                stli1.execute(query);
                ResultSet rs = stli1.executeQuery(query);
                while (rs.next()){
                    a= rs.getString("Part#");
//                    System.out.println("This is a: "+a);

                    b= rs.getString("Make");
//                    System.out.println("This is b: "+b);
                    if (b!=null){
                        b=b.replaceAll("'"," ");
                    }
//                    if (b.contains("'")){b=b.replaceAll("'", " ");}

                    c= rs.getString("Mdl");
//                    System.out.println("This is c: "+c);
                    if (c!=null){
                        c=c.replaceAll("'"," ");
                    }
//                    if (c.contains("'")){c=c.replaceAll("'", " ");}


                    d= rs.getString("ModelType");
//                    System.out.println("This is d: "+d);
                    if (d!=null){
                        d=d.replaceAll("'"," ");
                    }
//                    if (d.contains("'")){d=d.replaceAll("'", " ");}
//
//                    System.out.printf("%s, %s, %s,%s \n" ,a,b,c,d);





//
//                for(ResultSet rs3 = stli1.getResultSet(); rs3.next();)
//                    System.out.println(rs3);

//                    String[] invFields = {"Make","Mdl","ModelType","[Part#]"};

//                    for (int t=0; t<invFields.length;t++){
//                        invFields[t] = String.valueOf(stli1.getResultSet());
//                        JOptionPane.showMessageDialog(null,invFields[t].toString());

//                         a= invFields[0];
//                         b= invFields[1];
//                         c= invFields[2];
//                         d= invFields[3];
//                        System.out.println(a);
//                        System.out.println(b);
//                        System.out.println(c);
//                        System.out.println(d);




//                    //data read from DBli
//                    invid = rs3.getLong("invid");
//                    part_no = rs3.getString("part_no");
//                    quantity = rs3.getDouble("quantity");
//                    unitprice = rs3.getDouble("unitprice");
//                    description = rs3.getString("description");
//                    description1 = description.replace('\'', ' ');
                    try{
                        //push data from above to DBbl
                        // stli.execute("update tblinventory set Make='a', Mdl='b', ModelType='C' where [part#]='ad101';");
//                        System.out.println(" TO BKLI on next line ");
                        stbk1.execute("update tblinventory set Make='"+b+"', Mdl='"+c+"', ModelType='"+d+"' where [part#]='"+a+"';");
//                        System.out.println(" TO BKLI compelte ");
                        //stbk2.execute("INSERT INTO TBLBC_WORK ( [PART#], SUPPLIER, TYG_TX, TYG_TX_P, TYG_TX_QP, [TYG_TX#], description ) values('" + part_no + "', 'X', " + quantity + ", " + unitprice + ", " + unitprice + ", null, '" + description1 + "');");
                    }
                    catch(SQLException er) {
                        System.out.println("Error Occur at : "+a+" "+b+" "+c);
                        JOptionPane.showMessageDialog(null, er);
                    }
                }
                System.out.println("    COMPLETE    ");

            }
            catch(SQLException er)
            {
                er.printStackTrace();
                //JOptionPane.showMessageDialog(null, er);
            }

//            stli1.close();
//            stbk1.close();
//            stbk2.close();
//            conLI.close();
//            conBK.close();
        }
        catch(Exception e)
        {
            e.printStackTrace();
            //JOptionPane.showMessageDialog(null,e);
        }
    }
}
